package com.soft2018;

public class Character {

    private Skill skill;

    public Skill getSkill() {
        return skill;
    }

    public void setSill(Skill skill) {
        this.skill = skill;
    }

    // 怪物名 字段名 小写
    private String name;

    // 起名，对数据赋值，赋值方法
    public void setName(String name){
        this.name = name;
    }

    // 取值方法
    public String getName() {
        return name;
    }

    // 血量
    private int hp;

    // 取值器
    public void setHp(int m_hp) {
        this.hp = m_hp;
    }

    // 赋值器
    public int getHp() {
        return hp;
    }

    // 攻击力
    private int ap;

    public void setAp(int m_ap) {
        this.ap = m_ap;
    }

    public int getAp() {
        return ap;
    }

    //构造函数，用来初始化类对象
    public Character(){
        super();
    }
    //带参数构造函数，也是用来初始化类对象
    public Character(String name, int hp, int ap)
    {
        super();
        this.name = name;
        this.ap = ap;
        this.hp = hp;
    }

    public Character(String name, int hp, int ap, Skill skill)
    {
        super();
        this.name = name;
        this.ap = ap;
        this.hp = hp;
        this.skill = skill;
    }
    public Character(String name, int hp, int ap, int sap, String sinfo, String sname)
    {
        super();
        this.name = name;
        this.ap = ap;
        this.hp = hp;
        Skill skill = new Skill(sap,sinfo,sname);
        this.skill = skill;
    }


    //TODO:书写一个 print 函数，打印当前对象的状态信息
    public void print(){
        System.out.println(this.name+"当前血量："+this.hp+",当前攻击力:"+this.ap);
        if(this.skill != null)
        {this.skill.sprint();}
    }

    // 普通攻击方法
    public void attc(Character c)
    {
        c.dropHp(this.ap);
        System.out.println(this.name+"一记普通攻击，正中"+c.getName() + "，掉了"+this.ap+"血");
        System.out.println(c.name+"当前血量："+c.getHp());
    }

    // 技能攻击
    public void skill_attc(Character c)
    {
        c.dropHp(this.skill.getSap());
        System.out.println(this.name+"使出了："+this.skill.getSname()+
                ","+this.skill.getSinfo()+","+c.getName()+
                "掉了 "+this.skill.getSap()+" 滴血");
        System.out.println(c.name+"当前血量："+c.getHp());
    }

    //掉血
    public void dropHp(int attack)
    {
        this.hp -= attack;
    }

    //TODO：添加当前所在位置
    private int x;
    private int y;

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }
}
